/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
@use '@angular/material' as mat;
@use '@angular/material' as matm2;
@use '@angular/material' as matm2var;
@import 'tensorboard/webapp/theme/tb_theme';
@import '../common';

:host {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.toolbar {
  @include tb-theme-foreground-prop(border-bottom, border, 1px solid);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 $metrics-preferred-gap;

  metrics-tag-filter {
    flex: 1 1 100px;
  }

  .right-items {
    @include tb-theme-foreground-prop(border-left, border, 1px solid);
    margin-left: $metrics-preferred-gap;
    padding-left: $metrics-preferred-gap;
  }
}

// TODO(tensorboard-team): this component currently uses `mat-button-toggle-group` without
// projecting `mat-button-toggle` into it. This is an unsupported configuration that breaks
// with some upcoming Angular Material changes. The following patch aims to preserve the old
// appearance. Either the buttons should be replaced with `mat-button-toggle` or the
// `mat-button-toggle-group` should be removed.
mat-button-toggle-group.filter-view {
  @include tb-theme-foreground-prop(border, border, 1px solid);
}

.filter-view {
  border-radius: 4px;
  flex: none;
  margin-right: 5px;

  button {
    $_height: 25px;

    border-radius: 0;
    font-size: 12px;
    font-weight: normal;
    height: $_height;
    line-height: $_height;
    min-width: unset;
    padding: 0 12px;

    & + button {
      @include tb-theme-foreground-prop(border-left, border, 1px solid);
    }

    &[aria-checked='true'] {
      @include tb-theme-background-prop(background-color, selected-button);
    }
  }
}

.split-content {
  display: flex;
  overflow-y: auto;
  flex: 1;
}

.main,
.sidebar {
  contain: strict;
  background-color: matm2.get-color-from-palette($tb-background, background);
  overflow-x: hidden;
  overflow-y: auto;
  will-change: transform, scroll-position;

  @include tb-dark-theme {
    background-color: map-get($tb-dark-background, background);
  }
}

.main {
  background-color: matm2.get-color-from-palette($tf-slate, 200);
  flex: 1 1;
  display: flex;
  flex-direction: column;

  @include tb-dark-theme {
    // There are no slate color that looks very natural and nice.
    background-color: #3a3a3a;
  }

  metrics-filtered-view,
  metrics-pinned-view {
    @include tb-theme-foreground-prop(border-bottom, border, 1px solid);
  }

  &.filter-view {
    overflow: hidden;

    metrics-filtered-view {
      contain: content;
      overflow: auto;
      will-change: transform, scroll-position;
    }
  }
}

.loading-container {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.sidebar {
  @include tb-theme-foreground-prop(border-left, border, 1px solid);
  flex: 0 0 250px;

  .header {
    @include tb-theme-foreground-prop(border-bottom, border, 1px solid);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 42px;
    padding: 0 $metrics-preferred-gap;

    .title {
      font-size: 18px;
      font-weight: 400;
      line-height: normal;
      margin: 0;
    }
  }
}

/** TODO(psybuzz): consider making a tb-button instead. */
:host .settings-button {
  color: matm2.get-color-from-palette($tb-foreground, secondary-text);
  display: inline-flex;

  @include tb-dark-theme {
    color: matm2.get-color-from-palette($tb-dark-foreground, secondary-text);
  }

  &.checked {
    @include tb-theme-background-prop(background-color, selected-button);
    border-color: matm2.get-color-from-palette(matm2var.$grey-palette, 300);
  }

  ::ng-deep .mat-button-wrapper {
    display: inline-flex;
    align-items: center;
  }

  mat-icon {
    margin-right: 4px;
  }
}

.slide-out-menu {
  background-color: matm2.get-color-from-palette($tb-background, background);
  // Make the menu the full height minus the size of the toolbar.
  height: calc(100% - 49px);
  position: absolute;
  right: 50px;
  top: 49px;
  transition: all 0.75s ease;
  visibility: hidden;
  width: 200px;

  @include tb-theme-foreground-prop(border-left, border, 1px solid);

  @include tb-dark-theme {
    background-color: map-get($tb-dark-background, background);
  }
}

.slide-out-menu-expanded {
  right: 250px;
  visibility: visible;
}
